<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
    <meta content="text/html;charset=utf-8"></meta>
    <title>用户维护</title>
    <link rel="stylesheet" href="/static/js/common/bootstrap/css/bootstrap.min.css"></link>
    <link rel="stylesheet" href="/static/js/common/layer/theme/default/layer.css"></link>
    <link rel="stylesheet" href="/static/css/base.css"></link>

    <script src="/static/js/common/jquery/jquery-3.2.1.min.js"></script>
    <script src="/static/js/common/layer/layer.js"></script>
    <script src="/static/js/base/base.js"></script>
    <script>
        //记录翻页
        function listRecord(data, nowPageNo) {
            var pageSize = "${listResult.pageSize}";
            var url = "${basePath}" + "/sys/user/role/pageList";
            defaultPageRecord(pageSize, nowPageNo, url);
        }

        //删除记录
        function deleteRecord(data) {
            var url = "${basePath}" + "/sys/user/role/delete/";
            defaultDelRecord(data, url);
        }

        //修改模态窗弹出
        function modifyModal(data) {
            var requestUrl = "${basePath}" + "/sys/user/role/info/";
            var tdList = $(data).parent().parent().children();
            var id = tdList.eq(0).text();
            var url = requestUrl + id;
            getCommit(url,function (resultData) {
                asyncRefresh(resultData, $("#info_modify"));
                $('#modal_modify').modal('show');
                $("#queryId").attr("value", id);
            }, errorInfo);
        }

        //修改提交
        function modifyRecord() {
            var id = $("#queryId").val();
            var permissionIdArray = new Array();
            var checkedList = $("input[type='checkbox']:checked");
            $.each(checkedList, function (index, target) {
                permissionIdArray[index] = Number($(target).attr('value'));
            });
            var postData = {
                "roleIdList": permissionIdArray,
                "userId":id
            };
            var postUrl = "${basePath}" + "/sys/user/role/save/";
            defaultSaveRecord(JSON.stringify(postData), postUrl);
        }


    </script>
</head>
<body>
 <@_top.top 1/>
<div class="container" style="padding-bottom: 15px;min-height: 300px; padding-top: 60px;">
    <div class="row">
        <@_left.role 2/>
        <div class="col-md-10  col-xs-10">
            <h2>角色分配</h2>
            <hr>
            <form class="form-inline" id="queryForm" role="form">
                <input type="text" name="username" class="form-control" id="queryName" placeholder="请输入用户名称">
                <button type="button" onclick="listRecord(this)" class="btn btn-primary">查询</button>
                <#--<button type="button" class="btn btn-success" data-toggle="modal" data-target="#modal_add" >添加用户</button>-->
                <!-- 表示应谨慎采取的动作 -->
            </form>
            <hr>
            <div id="list_table">
                <table class="table table-hover table-bordered" id="role_grade">
                <#--<caption>悬停表格布局</caption>-->
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>用户名</th>
                        <#--<th>密码</th>-->
                    <#--<th>是否锁定</th>-->
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                <#list listResult.list as sysUser>
                <tr id="tr_${sysUser.id}">
                    <td style="display: none" id="id_${sysUser.id}">${sysUser.id}</td>
                    <td id="index">${sysUser_index  + 1}</td>
                    <td id="userName_${sysUser.id}">${sysUser.username?default("")}</td>
                    <#--<td id="password_${sysUser.id}">${sysUser.password?default("")}</td>-->
                <#--<td id="isLocked_${sysUser.id}">${(sysUser.isLocked)?string('是', '否')}</td>-->
                <#--<td id="isLocked_">yes</td>-->
                    <td>
                        <button id="update_${sysUser.id}" type="button" onclick="modifyModal(this)" class="btn btn-warning">修改</button>
                        <#--<button id="delete_${sysUser.id}" type="delete" onclick="deleteRecord(this)" class="btn btn-danger">删除</button>-->
                    </td>
                </tr>
                </#list>
                    </tbody>
                </table>
            </div>

            <nav aria-label="Page navigation" style="text-align: right">
                <ul class="pagination" id="table_pagging">
                    <#assign pageNum=listResult.totalPageNo>
                    <#if pageNum==0>
                        <#assign pageNum=1>
                    </#if>
                    <#list 1..pageNum as pn>
                        <li id="a_${pn}" class="${(pn==listResult.nowPageNo)?string('disabled','')}"><a onclick="${(pn==listResult.nowPageNo)?string('','listRecord(this, ${pn})')}" href="#" >${pn}</a></li>
                    </#list>
                </ul>
            </nav>

        </div>
    </div>
</div>

<div id="info_modify">
    <#--<#include "maintain_modify.ftl">-->
</div>


<script src="/static/js/common/bootstrap/js/bootstrap.min.js"></script>

</body>

</html>